import { getGlobalData } from '../../configuration/globaldata'

export const getsettlementMethod = settlementMethod => {
  let unit
  getGlobalData('settlementMethod').forEach(data => {
    if (settlementMethod == data.value) {
      unit = data.unit
    }
  })
  return unit
}

export const getunitMethod = (unitMethod, settlementMethod, type) => {
  let unit
  if((unitMethod == 0 || parseInt(unitMethod)) && type == 0) {
    getGlobalData('unitMethod').forEach(data => {
      if (unitMethod == data.value) {
        unit = `${data.unit}/${data.name}`
      }
    })
  } else {
    getGlobalData('settlementMethod').forEach(data => {
      if (settlementMethod == data.value) {
        unit = data.unit
      }
    })
  }
  return unit
}
export const getsettlementMethodName = settlementMethod => {
  let unit
  getGlobalData('settlementMethod').forEach(data => {
    if (settlementMethod == data.value) {
      unit = data.name
    }
  })
  return unit
}
export const getsettlementMethodNameShort = settlementMethod => {
  let unit
  getGlobalData('settlementMethod').forEach(data => {
    if (settlementMethod == data.value) {
      unit = data.short
    }
  })
  return unit
}
